<?php

require('../../../public/connection.php');
require('../../../class/Mysql.php');
$data = json_decode(file_get_contents('php://input'), true);
if ($data["money"]<=0 || $data["mode"]>2||empty($data["date"])) {
    die(json_encode(array("code" => 400, "msg" => "格式错误")));
}
$data["mode"] = (int)$data["mode"];
$time = getDateTime();
$add_one_data = new Mysql();
$result = $add_one_data->addOrEditData(
    "insert into incomes values(null,'{$data["date"]}','{$data["type"]}','{$data["source"]}',{$data["mode"]},{$data["money"]},'{$data["remarks"]}','{$time}');"
);
die(json_encode($result));